class MembershipDate < ActiveRecord::Base
  belongs_to :membership
  belongs_to :full_date
  
  validate :valid_event?
  
  #
  DATE_EVENTS = %w(Joined Left)
  
  def day
    return full_date.day
  end
  
  def month
    return full_date.month
  end
  
  def year
    return full_date.year
  end
  
  def date_string
    return full_date
  end
  
  def date_string_with_month
    return full_date.with_month
  end

  private
  
  #Validate that an accepted event was entered
  def valid_event?
    events = %w{ Joined Left }

    events.each do |valid_event|
      if event == valid_event
        return true
      end
    end
  end

  
end
